import torch, pickle, os,argparse,json
from glove import train,get_vocab_and_embed

if __name__ == "__main__":
    # file_path
    parser = argparse.ArgumentParser(description='generate word2vec by glove')
    parser.add_argument('--raw_data_path', type=str, default='/Users/qianghaozhang/Documents/PythonProject/NLP/retrans-crf/data/raw_data/',
                        help='the dir of raw data file,in this dir can contain more than one files')
    parser.add_argument('--train_data_path', type=str, default='/Users/qianghaozhang/Documents/PythonProject/NLP/retrans-crf/data/train_corpus/corpus.txt',
                        help='the path of train data file')
    parser.add_argument('--embed_path_txt', type=str, default="/Users/qianghaozhang/Documents/PythonProject/NLP/retrans-crf/data/export/Vector.txt",
                        help='the save path of word2vec with type txt')
    parser.add_argument('--embed_path_pkl', type=str, default="/Users/qianghaozhang/Documents/PythonProject/NLP/retrans-crf/data/export/Vector.pkl",
                        help='the save path of word2vec with type pkl,which is array after pickle.load ')
    parser.add_argument('--vocab_path', type=str, default='/Users/qianghaozhang/Documents/PythonProject/NLP/retrans-crf/data/export/vocab.json', help='the save path of vocab')
    parser.add_argument('--embed_dim', type=int, default=128, help='the dim of word2vec')
    parser.add_argument('--x_max', type=int, default=100, help='两个词共现出现的次数大于x_max后，衡量两词相似性的权重不再增加，论文推荐100')
    parser.add_argument('--alpha', type=float, default=0.75,
                        help='两个词共现出现的次数x小于x_max时，衡量两词相似性的权重为(x/x_max)^alpha 论文推荐0.75')
    parser.add_argument('--epoches', type=int, default=3, help='训练回合')
    parser.add_argument('--min_count', type=int, default=0, help='过滤掉出现小于min_count的词')
    parser.add_argument('--batch_size', type=int, default=64, help='训练批次')
    parser.add_argument('--windows_size', type=int, default=5, help='窗口大小')
    parser.add_argument('--learning_rate', type=int, default=0.001, help='学习率')
    args = parser.parse_args()
    train(args)
    # vec_eval.drawing_and_save_picture(save_picture_file_name)
    get_vocab_and_embed(args)